#include <stdio.h>
#include <inttypes.h>
#include "keyboard_hook.h"

// 事件分发回调函数
void cb(uint16_t keycode, uint16_t rawcode, uint16_t type) {
    printf("keycode=%u, rawcode=%u, type=%u\n", keycode, rawcode, type);
}

int main() {
    printf("Keyboard/Mouse Hook DLL Example\n");
    printf("Press ESC key to stop.\n\n");

    // 启动钩子
    int status = InstallHook(&cb);

    switch (status) {
        case UIOHOOK_SUCCESS:
            printf("Hook exited successfully.\n");
            break;

        case UIOHOOK_ERROR_OUT_OF_MEMORY:
            printf("Failed to allocate memory.\n");
            break;

        case UIOHOOK_ERROR_SET_WINDOWS_HOOK_EX:
            printf("Failed to register windows hook.\n");
            break;

        default:
            printf("An unknown hook error occurred.\n");
            break;
    }

    return status;
}
